package com.telecomyt.jwportal.activity;

import android.content.Context;
import android.content.Intent;
import android.widget.ImageView;

import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.telecomyt.jwportal.R;
import com.telecomyt.jwportal.base.BaseActivity;
import com.telecomyt.jwportal.base.BasePresenter;
import com.telecomyt.jwportal.widget.AvatarUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

public class TextActivity extends BaseActivity {
    List<String> stringList = new ArrayList<>();
    @BindView(R.id.mRecyclerView)
    RecyclerView mRecyclerView;
    MyAdapter myAdapter;

    public static void start(Context context) {
        Intent starter = new Intent(context, TextActivity.class);
        context.startActivity(starter);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_text;
    }

    private static final String url1 = "http://img1.3lian.com/2015/a2/251/d/296.jpg";
    private static final String url2 = "https://exp.bdstatic.com/static/exp-pc/common/widget/top-search-box/logo_1e63520.png";

    @Override
    protected void initView() {
        for (int i = 0; i < 100; i++) {
            stringList.add(url2);
        }
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        myAdapter = new MyAdapter(R.layout.activity_text_items, stringList);
        mRecyclerView.setAdapter(myAdapter);
    }


    @Override
    protected void initData() {

    }

    @Override
    protected BasePresenter creatPresenter() {
        return null;
    }


    private class MyAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
        public MyAdapter(int layoutResId, @Nullable List<String> data) {
            super(layoutResId, data);
        }

        @Override
        protected void convert(BaseViewHolder helper, String item) {
            ImageView mImageHead = helper.getView(R.id.mImageHead);
            AvatarUtils.setUserAvatar(mContext, mImageHead, "诚达", item);

        }
    }
}